import 'package:aoe_flutter/mvvm/bundle/bundle.dart';
import 'package:flutter/material.dart';

import 'widget_item_container.dart';

class CateCard extends StatefulWidget {
  final List<Bundle> bundles;
   String name;
  CateCard({@required this.bundles,@required this.name});
  @override
  _CateCardState createState() => _CateCardState();
}

class _CateCardState extends State<CateCard> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;
    widget.name = widget.name.replaceFirst(
        //首字母转为大写
        widget.name.substring(0, 1),
        widget.name.substring(0, 1).toUpperCase());
        
    return Container(
      width: screenWidth,
      padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 10.0),
      child: Stack(
        children: <Widget>[
          Container(
            width: screenWidth - 20,
            margin: const EdgeInsets.only(top: 10.0, bottom: 0.0),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(4.0),
            ),
            child: Column(
              children: <Widget>[
                // Container(
                //   width: screenWidth - 20,
                //   padding: const EdgeInsets.only(left: 10.0, top: 3.0),
                //   height: 30.0,
                //   child: Text(
                //     widget.name,
                //     style: TextStyle(
                //       color: Theme.of(context).primaryColor,
                //       fontSize: 18.0,
                //     ),
                //   ),
                // ),
                _buildWidgetContainer(),
              ],
            ),
          ),
          // Positioned(
          //   left: 0.0,
          //   top: 0.0,
          //   child: Container(
          //     height: 46.0,
          //     width: 60.0,
          //     decoration: BoxDecoration(
          //       color: Colors.white,
          //       borderRadius: BorderRadius.circular(30.0),
          //     ),
          //     child: Center(
          //       child: Container(
          //         decoration: BoxDecoration(
          //           color: Theme.of(context).primaryColor,
          //           borderRadius: BorderRadius.circular(23.0),
          //         ),
          //         height: 46.0,
          //         width: 46.0,
          //         child: Icon(
          //           // WidgetName2Icon.icons[widget.category.name],
          //           Icons.system_update,
          //           color: Colors.white,
          //           size: 30.0,
          //         ),
          //       ),
          //     ),
          //   ),
          // )
        ],
      ),
    );
  }

  Widget _buildWidgetContainer() {
    if (widget.bundles.length == 0) {
      return Container();
    }
    return Container(
      // padding: const EdgeInsets.only(bottom: 10.0, top: 5.0),
      // decoration: BoxDecoration(
      //   image: DecorationImage(
      //     image: AssetImage('images/3.0x/logodrive.png'),
      //     alignment: Alignment.bottomRight
      //   ),
      // ),
      child: WidgetItemContainer(
        bundles: widget.bundles,
        columnCount: 3,
        isWidgetPoint:false
      ),
    );
  }
}
